package com.xjrsoft.module.customerTwo.EMP.room_tools.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.EMP.room_tools.entity.TRoomTools;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.core.tool.utils.CollectionUtil;
import java.util.ArrayList;
import com.xjrsoft.module.customerTwo.EMP.room_tools.dto.TRoomToolsListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.EMP.room_tools.mapper.TRoomToolsMapper;
import com.xjrsoft.module.customerTwo.EMP.room_tools.service.ITRoomToolsService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author lisen
 * @since 2023-12-07
 */
@Service
@AllArgsConstructor
public class TRoomToolsServiceImpl extends BaseService<TRoomToolsMapper, TRoomTools> implements ITRoomToolsService {


	@Override
	public IPage<TRoomTools> getPageList(TRoomToolsListDto pageListDto) {
		Wrapper<TRoomTools> wrapper = Wrappers.<TRoomTools>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getTool_name()), TRoomTools::getToolName, pageListDto.getTool_name())
				.eq(!StringUtil.isEmpty(pageListDto.getCreater()), TRoomTools::getCreater, pageListDto.getCreater())
				.eq(!StringUtil.isEmpty(pageListDto.getCreate_date()), TRoomTools::getCreateDate, pageListDto.getCreate_date());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public Long addTRoomTools(TRoomTools tRoomTools) {
//		String tRoomToolsId = IdWorker.get32UUID();
//		tRoomTools.setFid(tRoomToolsId);
		boolean isSuccess = this.save(tRoomTools);
		return isSuccess ? tRoomTools.getFid() : null;
	}

	@Override
	public boolean updateTRoomTools(Long id, TRoomTools tRoomTools) {
		tRoomTools.setFid(id);
		return this.updateById(tRoomTools);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}